package main

import (
	"log"
	"os"
	"path/filepath"

	"workflow-gui/internal/encoding"
	"workflow-gui/internal/httpserver"
)

func main() {
	// Initialize UTF-8 encoding for Windows console
	encoding.InitUTF8()

	// Get database path
	exePath, err := os.Executable()
	if err != nil {
		log.Fatalf("Failed to get executable path: %v", err)
	}

	exeDir := filepath.Dir(exePath)
	dbPath := filepath.Join(exeDir, "..", "data", "workflow.db")

	// Create and start server
	server, err := httpserver.NewServer(9081, dbPath)
	if err != nil {
		log.Fatalf("Failed to create server: %v", err)
	}

	if err := server.Start(); err != nil {
		log.Fatalf("Server error: %v", err)
	}
}
